<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%pageContext.setAttribute("APP_PATH", request.getContextPath());%>
<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>竞单审核</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="${APP_PATH }/recourse/css/font.css">
    <link rel="stylesheet" href="${APP_PATH}/recourse/css/login.css">
    <link rel="stylesheet" href="${APP_PATH }/recourse/css/xadmin.css">
    <script type="text/javascript" src="${APP_PATH }/recourse/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="${APP_PATH }/recourse/js/xadmin.js"></script>

    <link rel="stylesheet" href="${APP_PATH }/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${APP_PATH }/recourse/css/formSelects-v4.css"/>

    <script type="text/javascript" src="${APP_PATH }/layui/layui.all.js"></script>
    <script type="text/javascript" src="${APP_PATH }/layui/lay/modules/layer.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>维修公司名称
            </label>
            <div class="layui-input-inline">
                <input readonly="readonly" type="text" id="name" name="name" required="" lay-verify="required"
                       autocomplete="off" class="layui-input" value="${bid.maintenance_company_name}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>预估价格
            </label>
            <div class="layui-input-inline">
                <input readonly="readonly" type="text" id="price" name="price" required="" lay-verify="required"
                       autocomplete="off" class="layui-input" value="${bid.estimated_price}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>预计开始时间
            </label>
            <div class="layui-input-inline">
                <input readonly="readonly" type="text" id="time" name="time" required="" lay-verify="required"
                       autocomplete="off" class="layui-input" value="<fmt:formatDate value="${bid.start_time}" type="date"/>">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>预计结束时间
            </label>
            <div class="layui-input-inline">
                <input readonly="readonly" type="text" id="times" name="times" required="" lay-verify="required"
                       autocomplete="off" class="layui-input" value="<fmt:formatDate value="${bid.finished_time}" type="date"/>">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">公司简述</label>
            <div class="layui-input-block">
                <textarea name="desc" readonly="readonly" class="layui-textarea" style="width: 300px;">${bid.bidding_description}</textarea>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">审批员:</label>
        <div class="layui-input-block" style="width: 300px;">
            <select name="reviewer" id="reviewr" lay-filter="reviewer" xm-select="reviewer" xm-select-type="1" multiple="true">
                <option value="">
                    无
                </option>
                <c:forEach items="${user_review}" var="option" >
                    <option value="${option.id}">
                            ${option.name}
                    </option>
                </c:forEach>
            </select>
        </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">撤销原因:</label>
            <div class="layui-input-block" style="width: 300px;">
                <select id="reason" name="reason" lay-verify="required">
                    <option value="无人竞单">
                        无人竞单
                    </option>
                    <option value="恶意竞单">
                        恶意竞单
                    </option>
                    <option value="该单不合理">
                        竞单不合理
                    </option>
                    <option value="其他">
                        其他
                    </option>
                </select>
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>撤销原因在选择撤销时起效
            </div>
        </div>
        <div class="layui-form-item">
            <button id = "add"  class="layui-btn" lay-filter="add"  style="margin-left: 150px;margin-top: 30px;">
            确认选择
            </button>
            <button id = "back"  class="layui-btn" lay-filter="add"  style="margin-left: 80px;margin-top: 30px;">
                撤销维修单
            </button>
        </div>

        <input id = "order_id" type="hidden" name="id" value="${bid.order_id}"/><br>
        <input id = "company_id" type="hidden" name="id" value="${bid.company_id}"/><br>
    </div>
</div>
<script type="text/javascript" src="${APP_PATH }/recourse/js/formSelects-v4.js"></script>
<script type="text/javascript">
    //全局定义一次, 加载formSelects
    layui.config({
        base: '/' //此处路径请自行处理, 可以使用绝对路径
    }).extend({
        formSelects: 'formSelects-v4'
    });
    //加载模块
    layui.use(['jquery', 'formSelects'], function () {
        var formSelects = layui.formSelects;
    });
</script>

<script>
    layui.use(['layer'], function() {
        var layer = layui.layer,
            $ = layui.jquery;
        $(document).on('click','#add', function () {
            var company_id = document.getElementById("company_id").value;
            var order_id = document.getElementById("order_id").value;
            var getName = layui.formSelects.value("reviewer","valStr");//取值name数组
            var completeData = {
                "comId":company_id,
                "viewId":getName,
                "orderId":order_id
            };
            if(confirm("是否确定该维修进行维修?")){
                $.ajax({
                    url:"${pageContext.request.contextPath}/approver/approveChooseCompany",
                    type : "POST",
                    dataType:"json",
                    contentType : "application/json;charset=UTF-8",
                    data: JSON.stringify(completeData),
                    success:function(data) {
                    }
                });
                layer.alert("操作成功", {
                        icon: 6
                    },
                    function() {
                        xadmin.close();
                        xadmin.father_reload();
                    });
            }else{
                return false;
            }

        });
    });


    layui.use(['layer'], function() {
        var layer = layui.layer,
            $ = layui.jquery;
        $(document).on('click', '#back', function () {
            var order_id = document.getElementById("order_id").value;
            var reason = document.getElementById("reason").value;
            var completeData = {
                "orderId":order_id,
                "reason":reason
            };
            if(confirm("是否确定该维修进行维修?")){
                $.ajax({
                    url:"${pageContext.request.contextPath}/approver/bidreject",
                    type : "POST",
                    dataType:"json",
                    contentType : "application/json;charset=UTF-8",
                    data: JSON.stringify(completeData),
                    success:function(data) {
                    }
                });
                layer.alert("操作成功", {
                        icon: 6
                    },
                    function() {
                        //关闭当前frame
                        xadmin.close();
                        // 可以对父窗口进行刷新
                        xadmin.father_reload();
                    });
            }else{
                return false;
            }
        });
    });
</script>
<script>var _hmt = _hmt || []; (function() {
    var hm = document.createElement("script");
    hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
})();
</script>
</body>

</html>

